package me.itblog.mvc.modules.admin;

import me.itblog.bean.User;
import me.itblog.mvc.filter.AdminAuthcActionFilter;
import me.itblog.mvc.modules.BaseModule;
import me.itblog.services.ArticleLuceneService;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.Scope;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Attr;
import org.nutz.mvc.annotation.By;
import org.nutz.mvc.annotation.Filters;
import org.nutz.mvc.annotation.Param;

/**
 * Created by infi.he on 2015/12/23.
 */
@IocBean()
@At("/admin/article")
@Filters(@By(type = AdminAuthcActionFilter.class))
public class AdminArticleModule extends BaseModule {

    @Inject
    ArticleLuceneService articleLuceneService;

    @At("/rebuild")
    public NutMap rebuild(@Param("oldPwd") String oldPwd,
                          @Param("newPwd") String newPwd, @Attr(scope = Scope.SESSION, value = "me") User me) throws Exception {
        articleLuceneService.rebuild();
        return ajaxOk("");
    }
}
